﻿Public Class AgregarHora 
    Public Sub Mostrar()
        If guardar.Enabled = False Then
            guardar.Enabled = True
            cancelar.Enabled = True
            agregar.Enabled = False
            modificar.Enabled = False
            eliminar.Enabled = False
            imprimir.Enabled = False
            PanelArriba.Enabled = True
            PanelAbajo.Enabled = False
        Else
            cancelar.Enabled = False
            guardar.Enabled = False
            agregar.Enabled = True
            Modificar.Enabled = True
            Eliminar.Enabled = True
            imprimir.Enabled = True
            PanelArriba.Enabled = False
            PanelAbajo.Enabled = True

        End If
    End Sub

    Private Sub HoraBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HoraBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.HoraBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbSolucionesEducativasDataSet)

    End Sub

    Private Sub AgregarHora_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.hora' table. You can move, or remove it, as needed.
        Me.HoraTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.hora)
        Mostrar()
    End Sub

    Private Sub agregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles agregar.Click
        BindingNavigatorAddNewItem.PerformClick()
        Mostrar()
    End Sub

    Private Sub modificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles modificar.Click
        Mostrar()
    End Sub

    Private Sub cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelar.Click
        ErrorProvider1.SetError(HrainicioTextBox, Nothing)
        Mostrar()
        Me.HoraTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.hora)
    End Sub

    Private Sub guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
        If HrainicioTextBox.Text.Length = 0 Then
            ErrorProvider1.SetError(HrainicioTextBox, "Debe ingresar una hora")
        Else
            ErrorProvider1.SetError(HrainicioTextBox, Nothing)


            HoraBindingNavigatorSaveItem.PerformClick()
            MessageBox.Show("Se guardó el resgistro satisfactoriamente")
            Mostrar()
        End If

    End Sub

    Private Sub PanelArriba_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PanelArriba.Paint
        'HrainicioDateTimePicker.Format = DateTimePickerFormat.Time
    End Sub

    Private Sub imprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imprimir.Click
        GridControl1.ShowPrintPreview()
    End Sub
End Class